import cx_Oracle
import pandas as pd

dsn_tns = cx_Oracle.makedsn('10.10.3.34', '1521', service_name='orcl')  # 数据库信息，注意是service_name，非SID
conn = cx_Oracle.connect(user='operation', password='operation', dsn=dsn_tns)  # 用户信息
c = conn.cursor()  # 创建连接
# c.execute("select * from T_1001_USER_OPERATION_LOG")  # 查询语句
# res = c.fetchall()
# print(res)  # 打印所有

file_path = r'C:\Users\DJ\Desktop\新建文件夹\新建文件夹\运营管理平台_管理员操作日志_2024年1季度.xlsx'
excel_data = pd.read_excel(file_path, header=[0])
x = excel_data.values.tolist()
for i, row in excel_data.iterrows():
    sql = "INSERT INTO T_1001_USER_OPERATION_LOG(MENU,BUTTON,URL,OPERATOR,OPERATION_TIME,IP) VALUES(:1,:2,:3,:4,:5,:6)"  ##ID1 ID2 .. 为表列名字
    c.execute(sql, tuple(row))
conn.commit()
c.close()
